﻿/// <reference path="utils.js" />
'use strict';

define([
    'common/models/billingItem.model',
], function (Model) {
    return Backbone.Collection.extend({
        model: Model,

        comparator: 'code',


        setRaw: function (data) {
            var newColl = [];

            _.each(data, function (item, i) {
                newColl.push(new Model({
                    id: item.Id,
                    billId: item.BillId,
                    productId: item.ProductId,
                    count: item.Count,
                    name: item.Name,
                    code: item.Code,
                    pricePerUnit: item.Price,
                }));
            });

            this.set(newColl);
        },
    });
});